﻿using ConsoleTables;
using Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Utils
{
    public class DisplayUtil
    {

        public static string dispalyInterfaces(List<Interface> interfaces)
        {
            ConsoleTable ct = new ConsoleTable(new string[]
            {
                "Name",
                "Description",
                "IpAddress",
                "Up"
            });
            foreach (var inter in interfaces)
            {
                ct.Rows.Add(new string[]
                {
                    inter.Name,
                    inter.Description,
                    inter.IpAddress,
                    inter.Up ? "UP" : "DOWN"
                });
            }
            return ct.ToStringAlternative();
        }

        public static string displayInterface(Interface inter)
        {
            ConsoleTable ct = new ConsoleTable(new string[]
            {
                "状态",
                "描述值"
            });
            ct.Rows.Add(new string[] { "ID", inter.Id });
            ct.Rows.Add(new string[] { "名称", inter.Name });
            ct.Rows.Add(new string[] { "描述", inter.Description });
            ct.Rows.Add(new string[] { "状态", inter.Up ? "UP" : "DOWN" });
            ct.Rows.Add(new string[] { "IP配置方式", inter.InterfaceConfigIpMethod.ToString() });
            ct.Rows.Add(new string[] { "IP地址", inter.IpAddress });
            ct.Rows.Add(new string[] { "子网掩码", inter.NetMask });
            ct.Rows.Add(new string[] { "默认网关", inter.DefaultGateway });
            ct.Rows.Add(new string[] { "DNS1", inter.DNS1 });
            ct.Rows.Add(new string[] { "DNS2", inter.DNS2 });
            return ct.ToStringNoBorder(false);
        }
    }
}
